package com.chezhujie.www.service;

import com.chezhujie.www.domain.Czjactivity;
import com.chezhujie.www.domain.vo.ActDetailAndFest;
import com.chezhujie.www.domain.vo.ActDetailAndFestAndUserVO;
import com.chezhujie.www.persistence.CzjactivityMapper;
import com.xy.core.page.Pagination;
import com.xy.core.utils.RandomUtil;
import com.xy.core.utils.UUIDUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class CzjactivityService {
   
	@Autowired
	private CzjactivityMapper czjactivityMapper;

	
	
	public void insertActivity(Czjactivity czjactivity) {
		if(StringUtils.isBlank(czjactivity.getActivityId())){
				czjactivity.setActivityId(UUIDUtils.getUUID());
		}
		czjactivityMapper.insertCzjactivity(czjactivity);
	}



	public Pagination listCzjactivityApi(Map<String, Object> map, Integer pageNo,
										 Integer pageSize) {
		
		Pagination p = new Pagination();
		p.setPageNo(pageNo);
		p.setPageSize(pageSize);
		map.putAll(p.toMap());
		int count=czjactivityMapper.getTotalApiRows(map);
		List<ActDetailAndFest> list=czjactivityMapper.listCzjactivityApi(map);
		p.setList(list);
		p.setTotalCount(count);
		return p;
		
	}



	public Pagination listCzjactivity(Map<String, Object> map, Integer pageNo,
			Integer pageSize) {
		Pagination p = new Pagination();
		p.setPageNo(pageNo);
		p.setPageSize(pageSize);
		map.putAll(p.toMap());
		int count=czjactivityMapper.getTotalQueryRows(map);
		List<ActDetailAndFest> list=czjactivityMapper.listCzjactivityQuery(map);
		p.setList(list);
		p.setTotalCount(count);
		return p;
	}



	public void updateAct(Czjactivity czjactivity) {
			
		czjactivityMapper.updateCzjactivity(czjactivity);
	}


	public ActDetailAndFest getActDetailAndFest(Map<String, Object> map) {
		return czjactivityMapper.getActDetailAndFest(map);
	}

    public Map<String,Object> getOrderedByNo(String orderNo) {
		return czjactivityMapper.getOrderedByNo(orderNo);
    }

    public Czjactivity queryById(String id) {
		return czjactivityMapper.queryById(id);
    }

    public void updateOrderStatus(String orderno,Integer orderStatus) {

		Map<String, Object> map = new HashMap<String, Object>();
		map.put("orderno", orderno);
		map.put("orderStatus", orderStatus);
		map.put("randStr", RandomUtil.getRandomString(6));
		czjactivityMapper.updateOrderStatus(map);
    }



	public int getPay1() {
		return czjactivityMapper.getPay1();
	}



	public int getPay2() {
		// TODO Auto-generated method stub
		return czjactivityMapper.getPay2();
	}



	public Integer getNum(String activityId) {
		return czjactivityMapper.getNum(activityId);
	}



	public ActDetailAndFestAndUserVO getActDeAndFestUser(String activityId) {
		return czjactivityMapper.getActDeAndFestUser(activityId);
	}



	


}
